# -*- coding: utf-8 -*-              

#这个文件不一定用。返回的是文字  不需要mediaId
import requests
import re

def img(url):
	im = requests.get(url).content

	url = 'https://how-old.net/Home/Analyze?isTest=False&source=&version=how-old.net'

	url = url.encode('utf-8')

	data = {'file':im}

	r = requests.post(url, files = data)

	r = r.content.decode('utf-8')

	r = r.replace('\\', '')

	gender = re.search(r'"gender": "(.*?)"rn',r)
	age = re.search(r'"age": (.*?),rn',r)

	if gender.group(1) == 'Male':
		gender = '男'
	else:
		gender = '女'

	datas = [gender,age.group(1)]

	

	return datas
	

# print img('http://imgsrc.baidu.com/imgad/pic/item/0e2442a7d933c89554b9f68ddb1373f083020004.jpg')